/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.ac.cput.ismaila.designPatterns.behavioural.visitor;

import java.util.List;

/**
 *
 * @author Chelsea
 */
public class SumVisitor implements NumberVisitor{
@Override
public String visit(TwoElement twoElement){
int sum = twoElement.a+twoElement.b;
return twoElement.a+"+"+twoElement.b+"="+sum;
}	
@Override
public String visit(ThreeElement threeElement){
int sum = threeElement.a+threeElement.b+threeElement.c;
return threeElement.a+"+"+threeElement.b+"+"+threeElement.c+"=-"+sum;
}
@Override
public String visit(List<NumberElement>elementList){
    String visited = "";
for(NumberElement ne:elementList){
visited = visited + ne.accept(this);
}
return visited;
}

}
